1.3.2安装

0，系统安装 debian 7.0
    0.1，apt-get install ssh # 源KEY问题：apt-get install debian-keyring debian-archive-keyring
    0.2，apt-get install apache2 php5 php5-ldap php5-mysql mysql-server php5-memcache php5-memcached memcached php5-gd php5-curl php5-mcrypt
    #设置mysql密码
    #php5enmod mcrypt
    0.3，a2enmod rewrite #apache rewrite模块
    0.4，vi /etc/php5/apache2/php.ini #搜索browscap，修改或添加
        browscap = $PROJECT_HOME$/config/lite_php_browscap.ini
    0.5，vi /etc/php5/cli/php.ini #搜索browscap，修改或添加
        browscap = $PROJECT_HOME$/config/lite_php_browscap.ini
    0.6，vi /etc/mysql/my.cnf #修改Mysql访问IP权限
        #bind-address = 127.0.0.1
    0.7，vi /etc/memcached.conf #修改Memcached访问IP权限
        #-l 127.0.0.1
    0.8，vi /etc/apache2/sites-enabled/88-default # 可选，使用IP，增加WEB目录指向
        <VirtualHost *:88>
                ServerAdmin webmaster@localhost
                DocumentRoot $PROJECT_HOME$/web
                <Directory />
                        Options FollowSymLinks
                        AllowOverride All
                </Directory>
                <Directory $PROJECT_HOME$/web/>
                        Options Indexes FollowSymLinks MultiViews
                        AllowOverride All
                        Order allow,deny
                        allow from all
                </Directory>
                RewriteLog ${APACHE_LOG_DIR}/rewrite-88.log
                RewriteLogLevel 0
                ErrorLog ${APACHE_LOG_DIR}/error-88.log
                CustomLog ${APACHE_LOG_DIR}/access-88.log combined
        </VirtualHost>
    0.9，vi /etc/apache2/port.conf # 可选，增加88端口
        Listen 88
    0.10，vi /etc/apache2/sites-enabled/sso-default # 可选，使用域名，增加WEB目录指向
        <VirtualHost *:80>
                ServerName sso.project.dcux.com
                DocumentRoot $PROJECT_HOME$/web/
                <Directory />
                        Options FollowSymLinks
                        AllowOverride All
                </Directory>
                <Directory $PROJECT_HOME$/web/>
                        Options Indexes FollowSymLinks MultiViews
                        AllowOverride All
                        Order allow,deny
                        allow from all
                </Directory>
                ErrorLog logs/error-sso.log
                CustomLog logs/access-sso.log combined
        </VirtualHost>
    0.11，Mysql数据库导入
    0.12，PHPBackend安装
    	0.12.1 执行如下命令，开户服务
    		cd /var/www/; php PHPBackend/server/socket/sso.php start -d 
    		# start|stop|restart|reload|status

1，拷贝SSO项目下的web,class,config,cmd,job等目录
2，web下cache,log目录加权：
    chmod 0777 web/cache web/log cmd/log job/log config/php_browscap
    2.1，图片分离
        # windows
            我的电脑 > 映射网络驱动器
            //192.168.0.19/dcux_data > z:
            SSO/web/目录下创建快捷方式images指向Z:\SSO\static\image

        # linux 
        #本地局域网，先挂载共享数据
            mount -t cifs -o username=nobody //192.168.0.19/dcux_data /dcux_data
        # svn co http://192.168.0.22:82/SSO_static_image /dcux_data/SSO/static/image
            ln -s /dcux_data/SSO/static/image $PROJECT_HOME$/web/images
        # 使用SSO_static_image库
        # svn co http://192.168.0.22:82/SSO_static_image $PROJECT_HOME$_static_image
            ln -s $PROJECT_HOME$_static_image $PROJECT_HOME$/web/images

3，修改config/env.php，设置使用的配置主文件，如：test => main.test.php
    3.1，使用新配置主文件，请参考其他配置主文件
4，修改web/js/env.js，设置前端使用的配置主文件，如：test => configuration['test'] #
    4.1，使用新配置，在web/js/config.js中增加新配置项
5，开启计划任务（可选）
    #5.1，根目录下创建job目录，并将项目链接，命令：ln -s $PROJECT_HOME$ /job/SSO
    5.2，给如下文件加权，命令如下：
        chmod +x $PROJECT_HOME$/bin/job/minutely.sh
        chmod +x $PROJECT_HOME$/bin/job/hourly.sh
        chmod +x $PROJECT_HOME$/bin/job/daily.sh
        chmod +x $PROJECT_HOME$/bin/job/weekly.sh
        chmod +x $PROJECT_HOME$/bin/job/monthly.sh
        chmod +x $PROJECT_HOME$/bin/job/yearly.sh
        chmod +x $PROJECT_HOME$/bin/server/sso.sh
    5.3，将job/sso.cron中的内容加入计划任务配置中，命令如下
        crontab -e
        注：集群情况下都要执行
	        */1 * * * * cd $PROJECT_HOME$/bin/job/; ./minutely.sh
			0 */1 * * * cd $PROJECT_HOME$/bin/job/; ./hourly.sh
			0 1 */1 * * cd $PROJECT_HOME$/bin/job/; ./daily.sh
			0 1 1 * * cd $PROJECT_HOME$/bin/job/; ./monthly.sh
			0 1 * * 1 cd $PROJECT_HOME$/bin/job/; ./weekly.sh
    5.4，执行如下命令
        ln -s $PROJECT_HOME$/bin/sso/online.php $PROJECT_HOME$/bin/job/minutely/sso.online.php #
        ln -s $PROJECT_HOME$/bin/sso/clean.php $PROJECT_HOME$/bin/job/minutely/sso.clean.php
        ln -s $PROJECT_HOME$/bin/oauth2/clean.php $PROJECT_HOME$/bin/job/minutely/oauth2.clean.php
        ln -s $PROJECT_HOME$/bin/sso/online5.php $PROJECT_HOME$/bin/job/minutely/sso.online5.php
        ln -s $PROJECT_HOME$/bin/sso/failure.php $PROJECT_HOME$/bin/job/daily/sso.dailyfailure.php
        ln -s $PROJECT_HOME$/bin/sso/dailyuser.php $PROJECT_HOME$/bin/job/daily/sso.dailyuser.php
        ln -s $PROJECT_HOME$/bin/sso/dailyclient.php $PROJECT_HOME$/bin/job/daily/sso.dailyclient.php
        ln -s $PROJECT_HOME$/bin/client/weekorder.php $PROJECT_HOME$/bin/job/weekly/client.weekorder.php
        ln -s $PROJECT_HOME$/bin/sso/monthclient.php $PROJECT_HOME$/bin/job/monthly/sso.monthclient.php #
        ln -s $PROJECT_HOME$/bin/browser/renovate.php $PROJECT_HOME$/bin/job/minutely/browser.renovate.php #
        ln -s $PROJECT_HOME$/bin/user/renovate.php $PROJECT_HOME$/bin/job/minutely/user.renovate.php #
        ln -s $PROJECT_HOME$/bin/server/clean.php $PROJECT_HOME$/bin/job/minutely/server.clean.php #
        注：集群情况下只需一台机器执行
6, 配置browscap
    6.1, 修改PHP5配置文件, 命令如下：
        vi /etc/php5/apache2/php.ini
        vi /etc/php5/cli/php.ini
    6.2, 找到browscap配置项并修改
        ...
        #browscap=*.ini
        browscap=$PROJECT_HOME$/config/lite_php_browscap.ini
        ...
7, 保持集群时间一致


8, PHPBackend
	chmod 0777 server/log
